package com.cx.common.util;

import com.cx.common.cons.CharacterCons;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * @author flysand
 * @package com.cx.common.util
 * @date 2021-11-07 18:45
 * @des DateUtils:
 */
public class DateUtils {


    public static String getDateString(DateType dateType) {
        switch (dateType) {
            case DATE:
                return LocalDate.now().toString();
            case DATE_TIME:
                return LocalDateTime.now().toString().replaceAll("T", CharacterCons.SPACE);
            case DATE_WITHOUT_SPLIT:
                return LocalDate.now().toString().replaceAll(CharacterCons.HYPHEN, CharacterCons.EMPTY);
            case DATE_TIME_WITHOUT_SPLIT:
                return LocalDateTime.now().toString().replaceAll(CharacterCons.HYPHEN, CharacterCons.EMPTY)
                        .replaceAll(CharacterCons.FULL_STOP,CharacterCons.EMPTY).replaceAll("T", CharacterCons.EMPTY)
                        .replaceAll(CharacterCons.COLON, CharacterCons.EMPTY);
            default:
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(getDateString(DateType.DATE));
        System.out.println(getDateString(DateType.DATE_TIME));
        System.out.println(getDateString(DateType.DATE_WITHOUT_SPLIT));
        System.out.println(getDateString(DateType.DATE_TIME_WITHOUT_SPLIT));
    }


    public static enum DateType {
        DATE,
        DATE_TIME,
        DATE_WITHOUT_SPLIT,
        DATE_TIME_WITHOUT_SPLIT;
    }
}
